package GUI;

import java.util.ArrayList;
import java.util.List;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

public class StatsTab extends JScrollPane {

    public class TabModel extends AbstractTableModel {

        private final List<Stats> statics = new ArrayList<>();
        private final String[] titre = {"Name", "Desription", "Action", "Time"};
        
        public List<Stats> getstats(){return statics;}
        
        public TabModel() {
            super();
        }

        @Override
        public int getRowCount() {
            return statics.size();
        }

        @Override
        public int getColumnCount() {
            return titre.length;
        }

        @Override
        public String getColumnName(int columnIndex) {
            return titre[columnIndex];
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            if (rowIndex < statics.size()) {
                switch (columnIndex) {
                    case 0:
                        return statics.get(rowIndex).getimg();
                    case 1:
                        return statics.get(rowIndex).getimei();
                    case 2:
                        return statics.get(rowIndex).getip();
                    case 3:
                        return statics.get(rowIndex).getdevice();
                    
                    default:
                        return null;
                }
            } else {
                return null;
            }
        }// */

        public void addStat(Stats stat) {
            int i=0;
            
            statics.add(stat);
            fireTableRowsInserted(statics.size() - 1, statics.size() - 1);
            
            
        }
        
        
    }

    public StatsTab() {
        jTable1.setModel(mymodel);
        this.setViewportView(jTable1);

    }
    JTable jTable1 = new javax.swing.JTable();
        GUI.StatsTab.TabModel mymodel = new GUI.StatsTab.TabModel();
        

}